<template>
  <div>
    <form @submit.prevent='fn' >
      <input type="text" name="username" v-model="form.username" />
      <input type="text" name="password" v-model="form.password"/>
      <button >提交</button>
    </form>
  </div>
</template>

<script>
  export default {
    //该vue组件的数据源
    data() {
      return {
        form: {
          username: '',
          password: '',
        },
      }
    },
    methods: {
      fn(){
        console.log(this.form.username , this.form.password);
      }

    },
  }
</script>

<style scoped></style>